package org.cuasloi.rabbitmq.work;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class WorkSpringRabbitListener {

    /* 使用@RabbitListener注解配置侦听哪个队列，方法参数就是消息内容 */
    @RabbitListener(queues = "work.queue")
    public void workQueueListener1(String msg) throws InterruptedException {
        System.out.println("----------接收到消息： " + msg);
        // 模拟每秒种可以处理50条消息
        Thread.sleep(20);
    }

    /* 使用@RabbitListener注解配置侦听哪个队列，方法参数就是消息内容 */
    @RabbitListener(queues = "work.queue")
    public void workQueueListener2(String msg) throws InterruptedException {
        System.out.println("==========接收到消息： " + msg);
        // 模拟每秒种可以处理5条消息
        Thread.sleep(200);
    }
}
